//
//  ScanResultViewController.m
//  LBXScanDemo
//
//  Created by lbxia on 15/11/17.
//  Copyright © 2015年 lbxia. All rights reserved.
//

#import "ScanResultViewController.h"
#import "SubLBXScanViewController.h"
#import "GCMSBXJXQViewController.h"

@interface ScanResultViewController ()

@end

@implementation ScanResultViewController{

    UIImageView * _imageV;
    UILabel * _labe;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createUI];

}
-(void)createUI{

    _imageV = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/4, 100, SCREEN_WIDTH/2, SCREEN_WIDTH/2)];
    _imageV.image = self.imgScan;
    [self.view addSubview:_imageV];
    _labe = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/4, SCREEN_WIDTH / 2 +120, SCREEN_WIDTH/2, 30)];
    _labe.text = self.strScan;
    [self.view addSubview:_labe];
    UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(0, SCREEN_HEIGHT - 50, SCREEN_WIDTH, 50)];
    button.backgroundColor = [UIColor colorWithRed:0.25 green:0.44 blue:0.63 alpha:1];
    [button setTitle:@"开始操作" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(onButtonClick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
}
-(void)onButtonClick{

    GCMSBXJXQViewController *xqVC = [[GCMSBXJXQViewController alloc]init];
    [self.navigationController pushViewController:xqVC animated:NO];
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] init];
    backItem.title = @"设备巡检详情";
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    self.navigationItem.backBarButtonItem = backItem;
    
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self setBackBar];
}
-(void)setBackBar{
    
    UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    backBtn.frame = CGRectMake(0, 0, 65, 44);
    
    [backBtn setImage:[UIImage imageNamed:@"back.png"] forState:UIControlStateNormal];
    [backBtn setTitle:@"返回" forState:UIControlStateNormal ];
    [backBtn addTarget:self action:@selector(doBack:) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn];
    self.navigationItem.leftBarButtonItem = backItem;
    
}
-(void)doBack:(id)sender
{
    NSMutableArray *marr = [[NSMutableArray alloc]initWithArray:self.navigationController.viewControllers];
    for (UIViewController *vc in marr) {
        if ([vc isKindOfClass:[SubLBXScanViewController class]]) {
            [marr removeObject:vc];
            break;
        }
    }
    self.navigationController.viewControllers = marr;
    [self.navigationController popViewControllerAnimated:YES];
}


@end
